<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>游戏测试</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background: #f0f0f0;
        }
        .test-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .test-section {
            margin: 20px 0;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        .test-button {
            background: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px;
        }
        .test-button:hover {
            background: #45a049;
        }
        .test-result {
            margin-top: 10px;
            padding: 10px;
            background: #f9f9f9;
            border-radius: 5px;
        }
        .error {
            color: red;
        }
        .success {
            color: green;
        }
    </style>
</head>
<body>
    <div class="test-container">
        <h1>游戏测试页面</h1>
        
        <div class="test-section">
            <h3>1. 基础测试</h3>
            <button class="test-button" onclick="testBasic()">测试基础功能</button>
            <div id="basic-result" class="test-result"></div>
        </div>
        
        <div class="test-section">
            <h3>2. 角色测试</h3>
            <button class="test-button" onclick="testCharacters()">测试角色创建</button>
            <div id="character-result" class="test-result"></div>
        </div>
        
        <div class="test-section">
            <h3>3. 卡牌测试</h3>
            <button class="test-button" onclick="testCards()">测试卡牌系统</button>
            <div id="card-result" class="test-result"></div>
        </div>
        
        <div class="test-section">
            <h3>4. 敌人测试</h3>
            <button class="test-button" onclick="testEnemies()">测试敌人系统</button>
            <div id="enemy-result" class="test-result"></div>
        </div>
        
        <div class="test-section">
            <h3>5. 游戏引擎测试</h3>
            <button class="test-button" onclick="testGameEngine()">测试游戏引擎</button>
            <div id="engine-result" class="test-result"></div>
        </div>
        
        <div class="test-section">
            <h3>6. 完整游戏测试</h3>
            <button class="test-button" onclick="testFullGame()">测试完整游戏</button>
            <div id="game-result" class="test-result"></div>
        </div>
    </div>

    <script src="js/characters.js"></script>
    <script src="js/cards.js"></script>
    <script src="js/enemies.js"></script>
    <script src="js/relics.js"></script>
    <script src="js/potions.js"></script>
    <script src="js/game.js"></script>
    
    <script>
        function testBasic() {
            const result = document.getElementById('basic-result');
            try {
                result.innerHTML = '<div class="success">✓ 基础功能正常</div>';
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 基础功能错误: ${error.message}</div>`;
            }
        }
        
        function testCharacters() {
            const result = document.getElementById('character-result');
            try {
                const xu = new Player('xu');
                const ling = new Player('ling');
                const che = new Player('che');
                
                result.innerHTML = `
                    <div class="success">✓ 角色创建成功</div>
                    <div>旭: ${xu.name}, 生命: ${xu.health}, 能量: ${xu.energy}</div>
                    <div>玲: ${ling.name}, 生命: ${ling.health}, 能量: ${ling.energy}</div>
                    <div>澈: ${che.name}, 生命: ${che.health}, 能量: ${che.energy}</div>
                `;
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 角色创建错误: ${error.message}</div>`;
            }
        }
        
        function testCards() {
            const result = document.getElementById('card-result');
            try {
                const card = new Card('测试卡牌', 1, 'attack', 5, '测试描述');
                result.innerHTML = `
                    <div class="success">✓ 卡牌系统正常</div>
                    <div>卡牌: ${card.name}, 消耗: ${card.cost}, 类型: ${card.type}</div>
                `;
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 卡牌系统错误: ${error.message}</div>`;
            }
        }
        
        function testEnemies() {
            const result = document.getElementById('enemy-result');
            try {
                const enemy = new Enemy('math_test', 1);
                result.innerHTML = `
                    <div class="success">✓ 敌人系统正常</div>
                    <div>敌人: ${enemy.name}, 生命: ${enemy.health}, 伤害: ${enemy.baseDamage}</div>
                `;
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 敌人系统错误: ${error.message}</div>`;
            }
        }
        
        function testGameEngine() {
            const result = document.getElementById('engine-result');
            try {
                const engine = new GameEngine();
                result.innerHTML = `
                    <div class="success">✓ 游戏引擎正常</div>
                    <div>当前屏幕: ${engine.currentScreen}</div>
                    <div>游戏状态: ${engine.gameState}</div>
                `;
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 游戏引擎错误: ${error.message}</div>`;
            }
        }
        
        function testFullGame() {
            const result = document.getElementById('game-result');
            try {
                const engine = new GameEngine();
                engine.selectedCharacter = 'xu';
                engine.startGame();
                
                result.innerHTML = `
                    <div class="success">✓ 完整游戏测试成功</div>
                    <div>玩家: ${engine.player ? engine.player.name : '未创建'}</div>
                    <div>卡组大小: ${engine.playerDeck ? engine.playerDeck.length : 0}</div>
                    <div>手牌数量: ${engine.playerHand ? engine.playerHand.length : 0}</div>
                    <div>敌人数量: ${engine.currentEnemies ? engine.currentEnemies.length : 0}</div>
                `;
            } catch (error) {
                result.innerHTML = `<div class="error">✗ 完整游戏测试错误: ${error.message}</div>`;
            }
        }
    </script>
</body>
</html>
